<template>
	<view class="wrap" style="padding-top:50rpx;">
		<view class="reg-text">欢迎注册</view>
		<view class="list">
			<view class="list-call">
				<view class="iconfont icon-shouji" style="font-size: 22px;color:#5473e8;"></view>
				<u-field v-model="phoneNo" label="+86" placeholder="请输入手机号码" style="width: 100%;">
				</u-field>
			</view>
		</view>
		<u-button class="btn-style" :ripple="true" shape="circle" @click="getCode()">获取验证码</u-button>
		<view class="bottom-box">
			<view class="copyright">
				注册即代表您已阅读并同意<u-link href="#">用户协议</u-link> 与 <u-link href="#">隐私政策</u-link>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				phoneNo: '',
			};
		},
		onLoad() {},
		methods: {
			getCode() {
				let reg = /^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/;
				if (reg.test(this.phoneNo)) {
					uni.showLoading({
						title: '正在获取验证码',
						mask: true
					})
					this.$u.api.sendCode({
							phoneNo: this.phoneNo,
							validCodeType: '1'
						})
						.then(res => {
							if (res.code == '200') {
								setTimeout(() => {
									uni.navigateTo({
										url: '/pages/sys/login/registerCode?phoneNo=' + this.phoneNo
									});
								}, 500);
							} else {
								this.$u.toast(res.msg);
							}
						});
				} else {
					uni.showToast({
						icon: 'none',
						title: '请输入正确的11位手机号',

					})
				}

			}
		}
	};
</script>
<style lang="scss">
	@import 'index.scss';

	.agreement {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 90rpx;
		color: #666;
	}

	.uni-input-placeholder {
		font-size: 32rpx;
	}

	.uni-input-input {
		font-size: 32rpx;
	}

	.bottom-box {
		position: fixed;
		bottom: 40rpx;
		text-align: center;
		width: 100%;
	}

	.copyright {
		text-align: center;
		color: #939393;
		width: 100%;
		font-size: 24rpx;

		.u-link {
			margin: 0 10rpx;
			font-size: 24rpx !important;
		}
	}
</style>